<?php
require_once 'common.php';
require_once 'Course.php';
require_once 'ResultData.php';
require_once "config.php";


if (isGet()) {
    echo "不得以GET访问";
    exit;
}

$id = trim($_REQUEST['id']);
$courseNo = trim($_REQUEST['courseNo']);
$courseName = trim($_REQUEST['courseName']);


$result = new ResultData();
if ($id == "") {
    $result->code = 404;
    $result->msg = "id不能为空";
    exit(json_encode($result));
}


$con = mysqli_connect($servername, $username, $password, $database, $port);

if (!$con) {
    $result->code = 404;
    $result->msg = "数据库连接不上";
    exit(json_encode($result));
}

$sql = "UPDATE t_course SET course_name = '{$courseName}', course_no='{$courseNo}' WHERE id = {$id};";

$con->query($sql);

mysqli_close($con);

exit(json_encode($result));
